import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

/**
 * Represents the main menu screen, with New Game and Load as options.
 */
public class MainMenuPanel extends JPanel{
	
	
	private JButton btnNewGame;	
	
	private Game game;
	
	/**
	 * Creates the main menu screen.
	 * @param g - the current game.
	 */
	public MainMenuPanel(Game g){

		game = g;
		
		setBorder(new EmptyBorder(5, 5, 5, 5));
		setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Oregon Trail");
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 24));
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setBounds(303, 181, 140, 58);
		add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("1842 Zombie Apocalypse!");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblNewLabel_1.setBounds(283, 232, 230, 38);
		add(lblNewLabel_1);
		
		btnNewGame = new JButton("New Game");
		btnNewGame.setFont(new Font("Tahoma", Font.BOLD, 12));
		btnNewGame.addActionListener(new ButtonHandler());
		btnNewGame.setBounds(321, 319, 127, 23);
		add(btnNewGame);
		
		//TODO Implement Load Game
		JButton btnLoadGamecoming = new JButton("Load Game (coming soon!)");
		btnLoadGamecoming.setFont(new Font("Tahoma", Font.BOLD, 12));
		btnLoadGamecoming.setEnabled(false);
		btnLoadGamecoming.setBounds(283, 365, 216, 23);
		add(btnLoadGamecoming);
	}
	
	/**
	 * Listener for the New Game and Load game buttons.
	 */
	private class ButtonHandler implements ActionListener {
		
		public void actionPerformed(ActionEvent buttonClick) 
		{	
			if (buttonClick.getSource().equals(btnNewGame)){				
				game.changePanel("ConfigurationPanel");
			}
		}
	}
}